package org.fusionide.builder.parsers.cfml.tags;

import java.util.Vector;

import org.fusionide.builder.parsers.IParserHandler;
import org.fusionide.builder.parsers.ParserException;
import org.fusionide.builder.parsers.cfml.CFMLTag;
import org.fusionide.builder.parsers.cfml.Variable;

public class Switch extends CFMLTag {
	public String expression;

	public Switch(String attributes, int startOffset) {
		super(attributes, startOffset);

		if (attributes == null)
			return;

		this.expression = getAttribute("expression");
	}

	@Override
	public boolean requiresClosingTag() {
		return true;
	}

	@Override
	public boolean validate(IParserHandler parserHandler) {
		if (super.validate(parserHandler)) {
			if (expression == null) {
				if (parserHandler != null)
					parserHandler.addMarker(new ParserException("<cfswitch> Requires expression attribute", ParserException.SEVERITY_ERROR, startLine));
				return false;
			}
			return true;
		}
		return false;
	}

	@Override
	public Vector<Variable> getVariables(int offset) {
		return super.getChildVariables(offset);
	}
}
